<template>
	<view @click="open">
		<view>
			<view v-if="item.mode==='base'" class="listcard">
				<view class="listcard-image">
					<image :src="item.cover[0]" mode="aspectFill"></image>
				</view>
				<view class="listcard-content">
					<view class="listcard-conent_title">
						<text>{{item.title}}</text>
						<likes :item='item'></likes>
					</view>
					<view class="listcard-conent_des">
						<view class="listcard-conent_des-label">
							<view class="listcard-conent_des-label-item">{{item.classify}}</view>
						</view>
						<view class="listcard-conent_des-browse">{{item.browse_count}}</view>
					</view>

				</view>
			</view>
		</view>

		<view>
			<view v-if="item.mode==='image'" class="listcard mode-image">

				<view class="listcard-content">
					<view class="listcard-conent_title">
						<text>{{item.title}}</text>
						<likes :item='item'></likes>
					</view>
					<view class="listcard-image">
						<view class="listcard-image_item">
							<image :src=item.cover[0] mode="aspectFill"></image>
						</view>

					</view>
					<view class="listcard-conent_des">
						<view class="listcard-conent_des-label">
							<view class="listcard-conent_des-label-item">{{item.classify}}</view>
						</view>
						<view class="listcard-conent_des-browse">{{item.browse_count}}</view>
					</view>

				</view>
			</view>
		</view>

		<view>
			<view v-if="item.mode==='column'" class="listcard mode-column">

				<view class="listcard-content">
					<view class="listcard-conent_title">
						<text>{{item.title}}</text>
						<likes :item='item'></likes>
					</view>
					<view class="listcard-image">
						<view v-if="index<3" v-for="(item,index) in item.cover" :key="index"
							class="listcard-image_item">
							<image :src="item" mode="aspectFill"></image>
						</view>
					</view>
					<view class="listcard-conent_des">
						<view class="listcard-conent_des-label">
							<view class="listcard-conent_des-label-item">{{item.classify}}</view>
						</view>
						<view class="listcard-conent_des-browse">{{item.browse_count}}</view>
					</view>

				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "list-card",
		props: {
			item: {
				type: Object,
				default () {
					return {}
				}
			}
		},
		data() {
			return {

			};
		},
		methods:{
			open(){
				console.log("打开")
				this.$emit('click',this.item)
				
				const params = {
					_id:this.item._id,
					title:this.item.title
				}
				
				uni.navigateTo({
					//传参不宜过长
					url:'../../pages/home-detail/home-detail?params='+JSON.stringify(params)
				})
			}
		}
	}
</script>

<style lang="scss">
	.listcard {
		display: flex;
		padding: 10px;
		margin: 10px;
		border-radius: 5px;
		box-shadow: 0 0 5px 1px rgba($color: #000000, $alpha: 0.1);
		box-sizing: border-box;

		.listcard-image {
			width: 60px;
			height: 60px;
			border-radius: 5px;
			overflow: hidden;
			flex-shrink: 0;

			image {
				width: 100%;
				height: 100%;
			}

			.listcard-image_item {
				display: flex;
				flex-direction: row;
			}
		}

		.listcard-content {
			width: 100%;
			padding-left: 10px;
			justify-content: space-between;
			display: flex;
			flex-direction: column;

			.listcard-conent_title {
				padding-right: 30px;
				color: #333;
				font-weight: 400;
				font-size: 14px;
				line-height: 1.2;
				position: relative;
				text {
					overflow: hidden;
					text-overflow: ellipsis;
					display: -webkit-box;
					-webkit-line-clamp: 2; //此处为上限行数
					-webkit-box-orient: vertical;
				}
				.icons {
					display: flex;
					justify-content: center;
					align-items: center;
					position: absolute;
					width: 20px;
					height: 20px;
					right: 0;
					top: 0;
					
				}
			}

			.listcard-conent_des {
				justify-content: space-between;
				font-size: 12px;
				display: flex;

				.listcard-conent_des-label {
					display: flex;

					.listcard-conent_des-label-item {
						padding: 0 5px;
						margin-right: 5px;
						border-radius: 5px;
						border: $mk-base-color 1px solid;
					}
				}

				.listcard-conent_des-browse {
					color: #999;
					line-height: 1.5;
				}
			}

		}

		&.mode-image {
			.listcard-content {
				width: 100%;
				padding-left: 10px;
			}

			.listcard-image {
				display: flex;
				margin: 10px;
				width: 100%;
				height: 70px;

				.listcard-image_item {
					margin-left: 10rpx;
					width: 100%;
					border-radius: 5px;
					overflow: hidden;

					&:first-child {
						margin-left: 0;
					}

					image {
						width: 100%;
						height: 100%;
					}
				}
			}
		}

		&.mode-column {
			.listcard-content {
				width: 100%;
				padding-left: 0;
			}

			.listcard-image {
				display: flex;
				margin-top: 10px;
				width: 100%;
				height: 70px;

				.listcard-image_item {
					margin-left: 10px;
					width: 100%;
					border-radius: 5px;
					overflow: hidden;

					&:first-child {
						margin-left: 0;
					}

					image {
						width: 100%;
						height: 100%;
					}
				}
			}

			.listcard-content__des {
				margin-top: 10px;
			}
		}
	}
</style>
